package net.lab1024.sa.admin.module.business.erp.sao.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SaordAddForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SaordQueryForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.form.SaordUpdateForm;
import net.lab1024.sa.admin.module.business.erp.sao.domain.vo.SaordVO;
import net.lab1024.sa.admin.module.business.erp.sao.service.SaordService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.sql.SQLException;

/**
 * 采购订单 Controller
 *
 * @Author AKITA
 * @Date 2025-07-23 20:52:44
 * @Copyright AKITA
 */

@RestController
@Tag(name = "采购订单")

@OperateLog
public class SaordController {

    @Resource
    private SaordService saordService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/saord/queryPage")
    public ResponseDTO<PageResult<SaordVO>> queryPage(@RequestBody @Valid SaordQueryForm queryForm) {
        return ResponseDTO.ok(saordService.queryPage(queryForm));
    }


    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/saord/add")
    public ResponseDTO<Long> add(@RequestBody @Valid SaordAddForm addForm) {
        return saordService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/saord/update")

    public ResponseDTO<String> update(@RequestBody @Valid SaordUpdateForm updateForm) {
        return saordService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/saord/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return saordService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/saord/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return saordService.delete(id);
    }


    @Operation(summary = "分页查询 @author AKITA")
    @GetMapping("/print/saord/{id}")
    public void print(@PathVariable Long id, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {

        saordService.print(id, request, response);
    }


    @Operation(summary = "单个查询 @author AKITA")
    @GetMapping("/saord/info/{id}")
    public ResponseDTO<SaordVO> info(@PathVariable Long id) {
        return saordService.info(id);
    }

    @Operation(summary = "单个查询 @author AKITA")
    @GetMapping("/saord/infoUnexecute/{id}")
    public ResponseDTO<SaordVO> infoUnexecute(@PathVariable Long id) {
        return saordService.infoUnexecute(id);
    }

    @Operation(summary = "单个查询 @author AKITA")
    @GetMapping("/saord/infoUnexecuteBack/{id}")
    public ResponseDTO<SaordVO> infoUnexecuteBack(@PathVariable Long id) {
        return saordService.infoUnexecuteBack(id);


    }


}
